<?php
class Log {
		
		static public $Log = array();
		static private $fileName = "errorLog.txt";
		
		/**
		 * @param $str erorrmessage to be logged
		 * @param $var Additional string for extra information; "This one sure is buggy, fix now"".
		 */
		static public function LogMessage($str, $var = NULL, $type = "log") {
			$time = time();
			
			self::$Log[] = array($time, $str, $var, $type);
			
			return $time;
		}
		
		static public function LogError($str) {
			$time = self::LogMessage($str, NULL, "error");
			
			$fileHandler = fopen(self::$fileName, 'a') or die("can't open file");
			
			$stringData = "[" . date("F j, Y G:i", $time) ."]" . $_SERVER["REMOTE_ADDR"] . "\n". $_SERVER["HTTP_USER_AGENT"]. "\n" . " $str.\n";
			
			fwrite($fileHandler, $stringData);
			
			fclose($fileHandler);
		}
	}